﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web;
using System.IO;
using ECI.CoreLibrary.Common;

namespace ECI.LIP.Management
{
    public class Utis
    {
        public static string GetTeplate(string path)
        {
            FileStream fs = new FileStream(PageHelper.ServerPath + "\\" + path, FileMode.Open, FileAccess.Read);
            StreamReader strHtml = new StreamReader(fs, Encoding.UTF8);
            string strV = strHtml.ReadToEnd();
            strHtml.Close();
            fs.Close();
            return strV;
        }

        public static void Alert(string message, string type)
        {
            try
            {
                message = message.Replace("\"", ".");
                Page page = (Page)HttpContext.Current.Handler;
                string script = string.Format("" + type + "('{0}     ');", message.Replace("'", "\\'").Replace("\"", "&#34;").Replace("\t\n", "").Replace("\n", "").Replace("'", "").Replace("'", "").Replace("\r", ""));
                page.ClientScript.RegisterStartupScript(page.GetType(), Guid.NewGuid().ToString(), script, true);
            }
            catch
            {
            }
        }

        public static void Alert(string message)
        {
            try
            {
                message = message.Replace("\"", ".");
                Page page = (Page)HttpContext.Current.Handler;
                string script = string.Format("alertOK('{0}     ');", message.Replace("'", "\\'").Replace("\"", "&#34;").Replace("\t\n", "").Replace("\n", "").Replace("'", "").Replace("'", "").Replace("\r", ""));
                page.ClientScript.RegisterStartupScript(page.GetType(), Guid.NewGuid().ToString(), script, true);
            }
            catch
            {
            }
        }


        public static void alertWarin(string message)
        {
            Alert(message, "alertWarin");
        }

        public static void AlertOk(string message)
        {
            Alert(message, "alertOK");
        }

        public static void AlertFail(string message)
        {
            Alert(message, "alertFail");
        }
    }
}
